//
//  labelview.m
//  单例小例子
//
//  Created by xuping on 15/9/18.
//  Copyright (c) 2015年 xuping. All rights reserved.
//

#import "labelview.h"

@implementation labelview

-(void)setimage:(NSString *)img tit:(NSString *)title buttontit:(NSString *)butst frem:(CGRect)cgf
{
        self.frame=cgf;
        
        if (img!=nil) {
            
            _image=[[UIImageView alloc]init];
            _image.frame=CGRectMake((self.frame.size.width-100)/2, 100, 100, 100);
            _image.image=[UIImage imageNamed:img];
            [self addSubview:_image];
        }
    
        _label=[[UILabel alloc]init];
        _label.frame=CGRectMake(50,205, self.frame.size.width-100, 40);
        _label.text=title;
        _label.textAlignment=NSTextAlignmentCenter;
        _label.numberOfLines=0;
        _label.font=[UIFont systemFontOfSize:14];
        _label.textColor=[UIColor grayColor];
        [self addSubview:_label];
        
        
        if (butst!=nil) {
            
            _button=[[UIButton alloc]init];
            _button.frame=CGRectMake(40, 240, self.frame.size.width-80, 40);
            [_button.layer setMasksToBounds:YES];
            [_button.layer setCornerRadius:20.0]; //设置矩圆角半径
            UIImage*loginOldImg=[UIImage imageNamed:@"blueBtn"];
            UIImage*loginNewImg=[loginOldImg stretchableImageWithLeftCapWidth:19 topCapHeight:0];
            [_button setBackgroundImage:loginNewImg forState:UIControlStateNormal];
            [_button addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];
            [_button setTitle:butst forState:UIControlStateNormal];
            [self addSubview:_button];
            
        }
        
    
    
}
-(void)action
{
    if ([self.delegate respondsToSelector:@selector(didClickButtonInBottomView)]) {
        [self.delegate didClickButtonInBottomView];
    }
    
    [self removeFromSuperview];
    
}

//重写allocWithZone方法，用来保证其他人直接使用alloc和init试图获得一个新实力的时候不产生一个新实例，
@end

